package Manage;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import Info.TongjiI;
import Util.DatabaseConn;

public class TongjiM {
		public List<TongjiI> findAll() {
			List<TongjiI> tongjis = new ArrayList<TongjiI>();
			Connection conn = null;
			try {
				conn = DatabaseConn.getConnection();
				PreparedStatement prep = conn.prepareStatement("select * from tongji");
				ResultSet rs = prep.executeQuery();
				while (rs.next()) {
					int id = rs.getInt("id");
					String name = rs.getString("name");
					String count = rs.getString("count");
					TongjiI k = new TongjiI(id,name,count);
					tongjis.add(k);
				}
			} catch (Exception e) {

			} finally {
				DatabaseConn.closeConn(conn);
			}
			return tongjis;
		}
}
